import sys
import datetime
from logic import adminDao
sys.path.append("../")
#各种过滤
class authFilter():
    #登陆过滤
    def auth(req):
        def wrapper(*args,**kw):
            reqobj = args[0]
            try:
                jwtstr = reqobj.get_cookie("coreid")
                if not jwtstr == None:
                    if not adminDao.adminDao.checkJwt(jwtstr):
                        reqobj.redirect("/admin/login")
                        return
                else:
                    reqobj.redirect("/admin/login")
                    return
            except Exception:
                reqobj.redirect("/admin/login")
                return
            return req(*args,**kw)
        return wrapper